<script setup lang="ts">
import { Position, Search, Refresh, Plus, Delete, Edit, Upload, Download, CircleCheck, Select } from "@element-plus/icons-vue";
import { useAttrs } from "vue";

const emit = defineEmits(["click"]);
const attrs = useAttrs();

interface Props {
  type?: string;
}

const props = withDefaults(defineProps<Props>(), {
  type: "default"
});
</script>

<template>
  <!-- 新增 -->
  <el-button v-if="type == 'add_icon_text'" v-bind="{ ...attrs }" :icon="Plus" type="primary" @click="emit('click')">
    <slot>新增</slot>
  </el-button>
  <el-tooltip v-if="type == 'add_icon'" placement="top" content="新增">
    <el-button v-bind="{ ...attrs }" circle type="primary" :icon="Plus" @click="emit('click')" />
  </el-tooltip>
  <el-button v-if="type == 'add_text'" v-bind="{ ...attrs }" type="primary" link>
    <slot>新增</slot>
  </el-button>
  <!-- 编辑 -->
  <el-button v-if="type == 'edit_icon_text'" v-bind="{ ...attrs }" :icon="Edit" type="primary">编辑</el-button>
  <el-button v-if="type == 'edit_text_plain'" v-bind="{ ...attrs }" type="primary" plain>编辑</el-button>
  <el-button v-if="type == 'edit_text'" v-bind="{ ...attrs }" type="primary" link>编辑 </el-button>

  <el-tooltip v-if="type == 'edit_icon'" placement="top" content="编辑">
    <el-button v-bind="{ ...attrs }" circle type="primary" :icon="Edit" @click="emit('click')" />
  </el-tooltip>
  <!-- 删除 -->
  <el-tooltip v-if="type == 'del_icon'" placement="top" content="删除">
    <el-button v-bind="{ ...attrs }" circle type="danger" :icon="Delete" @click="emit('click')" />
  </el-tooltip>
  <el-button v-if="type == 'del_icon_text'" v-bind="{ ...attrs }" :icon="Delete" type="danger" @click="emit('click')"
    >删除
  </el-button>
  <!-- 删除 -->
  <el-button v-if="type == 'del_text'" v-bind="{ ...attrs }" link type="danger" @click="emit('click')">删除</el-button>

  <el-button v-if="type == 'del_text_plain'" v-bind="{ ...attrs }" type="danger" plain @click="emit('click')">删除</el-button>
  <!-- 搜索 -->
  <el-button v-if="type == 'search_icon_text'" v-bind="{ ...attrs }" :icon="Search" type="primary" @click="emit('click')"
    >搜索
  </el-button>
  <!-- 重置 -->
  <el-button v-if="type == 'reset_icon_text'" v-bind="{ ...attrs }" :icon="Refresh" @click="emit('click')">重置</el-button>
  <!-- 刷新 -->
  <el-button v-if="type == 'refresh_icon_text'" v-bind="{ ...attrs }" :icon="Refresh" @click="emit('click')">刷新</el-button>
  <!-- 导入 -->
  <el-button v-if="type == 'import_icon_text'" v-bind="{ ...attrs }" :icon="Upload" type="primary" @click="emit('click')"
    >导入
  </el-button>
  <!-- 导出 -->
  <el-button v-if="type == 'export_icon_text'" v-bind="{ ...attrs }" :icon="Download" type="success" @click="emit('click')"
    >导出
  </el-button>
  <!-- 保存 -->
  <el-button
    size="small"
    v-if="type == 'save_icon_text'"
    v-bind="{ ...attrs }"
    :icon="Select"
    type="primary"
    @click="emit('click')"
    >保存
  </el-button>
  <el-button v-if="type == 'save_large_icon_text'" v-bind="{ ...attrs }" :icon="Select" type="primary" @click="emit('click')"
    >保存
  </el-button>
  <!-- 修改密码 -->
  <el-button v-if="type == 'password_text_plain'" v-bind="{ ...attrs }" type="warning" plain @click="emit('click')"
    >修改密码
  </el-button>
  <!-- 下载 -->
  <el-button v-if="type == 'download_text_plain'" v-bind="{ ...attrs }" type="success" plain @click="emit('click')"
    >下载
  </el-button>
  <el-button v-if="type == 'download_icon_text'" v-bind="{ ...attrs }" :icon="Download" type="success" @click="emit('click')"
    >下载
  </el-button>
  <el-tooltip v-if="type == 'download_icon'" placement="top" content="下载">
    <el-button
      v-if="type == 'download_icon'"
      v-bind="{ ...attrs }"
      :icon="Download"
      @click="emit('click')"
      type="success"
      circle
    ></el-button>
  </el-tooltip>
</template>

<style scoped></style>
